package com.ant.storage.controller;


import com.ant.storage.common.ResultVo;
import com.ant.storage.pojo.DataMsg;
import com.ant.storage.service.IDataMsgService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hzd
 * @since 2024-07-19
 */
@RestController
@RequestMapping("/data-msg")
public class DataMsgController {

    @Autowired
    IDataMsgService msgService;

    @ApiOperation(value = "获取员工列表")
    @GetMapping("/queryList")
    public ResultVo queryList() {
        List<DataMsg> list = msgService.list();
        return ResultVo.success("操作成功",list);
    }

    @ApiOperation(value = "添加角色")
    @PostMapping("/save")
    public ResultVo save(@RequestBody DataMsg msg) {
        if (msg.getId() == null) {
            msgService.save(msg);
        } else {
            msgService.updateById(msg);
        }
        return ResultVo.success("操作成功");
    }
}
